package com.tuanzi.loan.business.service.family.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.tuanzi.loan.core.aspect.Debug;

import com.tuanzi.loan.business.service.family.MobileCodeSendRecordService;
import com.tuanzi.loan.vo.request.family.MobileCodeSendRecordSearchRequest;
import com.tuanzi.loan.vo.response.family.MobileCodeSendRecordSearchResponse;
import com.tuanzi.loan.business.repository.family.MobileCodeSendRecordRepository;
import com.tuanzi.loan.core.vo.PageSearcher;
import org.springframework.data.domain.Page;
import java.util.Objects;

/**
 * 手机验证码发送记录 ServiceImplement
 * @author JinRuiyang 2017/12/21 17:03:46
 */
@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class MobileCodeSendRecordServiceImpl implements MobileCodeSendRecordService {

    @Autowired
    private MobileCodeSendRecordRepository mobilecodesendrecordRepository;


    /**
     * MobileCodeSendRecord查询
     * @param pageSearcher 请求信息
     * @return 响应列表
     */
    public Page<MobileCodeSendRecordSearchResponse> list(PageSearcher<MobileCodeSendRecordSearchRequest> pageSearcher) {
        if (Objects.isNull(pageSearcher))
            throw new NullPointerException("pageSearcher is null");
        if (Objects.isNull(pageSearcher.getSearchCondition()) || Objects.isNull(pageSearcher.getPageable()))
            throw new NullPointerException("mobilecodesendrecordSearchRequest or pageable is null");
        return mobilecodesendrecordRepository.list(pageSearcher.getSearchCondition(),pageSearcher.getPageable());
    }
}